package com.hb.trade.server.project.notice.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hb.core.pojo.enums.CommonTypeEnum;
import com.hb.core.pojo.enums.DeployStatusEnum;
import com.hb.core.pojo.enums.NoticeNatureEnum;
import com.hb.core.pojo.parent.MPBaseController;
import com.hb.core.pojo.parent.PageResult;
import com.hb.core.pojo.project.notice.dto.*;
import com.hb.core.pojo.project.notice.entity.Notice;
import com.hb.core.pojo.project.notice.entity.NoticeBidSection;
import com.hb.core.pojo.project.notice.vo.NoticeListVo;
import com.hb.core.pojo.project.proj.entity.AbstractProject;
import com.hb.core.pojo.project.section.dto.BidSectionDTO;
import com.hb.core.pojo.project.section.entity.BidSection;
import com.hb.trade.server.project.notice.manager.NoticeManager;
import com.hb.trade.server.project.notice.manager.NoticeSave;
import com.hb.trade.server.project.notice.service.NoticeBidSectionService;
import com.hb.trade.server.project.notice.service.NoticeService;
import com.hb.trade.server.project.notice.service.TenderInviteEnterpriseService;
import com.hb.trade.server.project.proj.service.ProjectService;
import com.hb.trade.server.project.section.manager.BidSectionManager;
import com.hb.trade.server.project.section.service.raw.BidSectionService;
import com.hb.trade.server.project.util.DateUtil;
import org.fzzn.core.model.enums.LogicEnum;
import org.fzzn.core.model.enums.MsgEnum;
import org.fzzn.core.model.msg.Message;
import org.fzzn.core.util.Enums;
import org.fzzn.core.util.MsgUtil;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 公告信息表 前端控制器
 * </p>
 *
 * @author zhaojk
 * @since 2021-08-30
 */
@RestController
public class NoticeController extends MPBaseController<Notice, NoticeService> {

    protected final ProjectService projectService;
    protected final BidSectionService bidSectionService;
    protected final NoticeBidSectionService noticeBidSectionService;
    protected final TenderInviteEnterpriseService tenderInviteEnterpriseService;

    public NoticeController(NoticeService noticeService,
                            ProjectService projectService,
                            BidSectionService bidSectionService,
                            NoticeBidSectionService noticeBidSectionService,
                            TenderInviteEnterpriseService tenderInviteEnterpriseService) {
        super(noticeService);
        this.projectService = projectService;
        this.bidSectionService = bidSectionService;
        this.noticeBidSectionService = noticeBidSectionService;
        this.tenderInviteEnterpriseService = tenderInviteEnterpriseService;
    }

    /**
     * 新增最高限价公告
     *
     * @param priceDto
     * @return
     */
    @Transactional
    @PostMapping("/notice/saveLimitPriceNotice")
    public Message<Boolean> saveLimitPriceNotice(@RequestBody NoticeLimitPriceDTO priceDto) {
        // 保存公告信息
        Notice notice = new Notice();
        // 最高限价公告
        notice.setNoticeNature(7);
        notice.setAttachment(priceDto.getAttachment());
        notice.setNoticeContent(priceDto.getContent());
        notice.buildBaseData(1);
        // 如果ID不为空, 则去修改这条记录
        if (priceDto.getNoticeId() != null) {
            notice.setId(priceDto.getNoticeId());
        }
        boolean save = service.saveOrUpdate(notice);

        // 最高限价信息保存至标段表中
        List<NoticeLimitPriceDTO.LimitPriceDto> limitPrices = priceDto.getLimitPrices();
        for (NoticeLimitPriceDTO.LimitPriceDto limitPriceDto : limitPrices) {
            BidSection bidSection = bidSectionService.getById(limitPriceDto.getSectionId());
            if (bidSection == null) {
                continue;
            }
            limitPriceDto.setNoticeId(notice.getId());
            bidSection.setLimitConfigInfo(JSONUtil.toJsonStr(limitPriceDto));
            bidSectionService.updateById(bidSection);
        }
        return MsgUtil.msg(save);
    }

    /**
     * 最高限价查看
     *
     * @param bidSectionDto
     * @return
     */
    @PostMapping("/notice/info/limitPriceNotice")
    public Message<NoticeLimitPriceDTO> infoLimitPriceNotice(@RequestBody NoticeBidSectionDTO bidSectionDto) {
        Long sectionId = bidSectionDto.getSectionId();
        if (sectionId == null) {
            return MsgUtil.fail("标段ID不能为空");
        }
        // 前端显示对象
        NoticeLimitPriceDTO limitPriceDto = new NoticeLimitPriceDTO();
        // 查询一个标段, 为获取项目ID
        List<BidSection> bidSections = bidSectionService.listSections(sectionId);
        if (CollUtil.isEmpty(bidSections)) {
            return MsgUtil.fail("未查询到任何标段信息");
        }
        BidSectionManager sectionManager = bidSections.get(0).to(BidSectionManager.class);
        NoticeLimitPriceDTO.LimitPriceDto configIns = sectionManager.getLimitPriceConfigIns();

        if (configIns != null) {
            Long noticeId = configIns.getNoticeId();
            if (noticeId != null) {
                // 查询公告中的附件内容(每个标段对应的公告是同一个)
                Notice notice = service.getById(noticeId);
                limitPriceDto.setAttachment(notice.getAttachment());
                limitPriceDto.setNoticeId(notice.getId());
            }
        }
        // 查询项目信息
        AbstractProject project = projectService.getById(bidSections.get(0).getProjectId());
        limitPriceDto.setProjectCode(project.getProjectCode());
        limitPriceDto.setProjectName(project.getProjectName());
        // 返回标段信息列表
        List<NoticeLimitPriceDTO.LimitPriceDto> limitPriceDtos = CollUtil.list(false);
        for (BidSection bidSection : bidSections) {
            BidSectionManager sectionManager1 = bidSection.to(BidSectionManager.class);
            NoticeLimitPriceDTO.LimitPriceDto limitPriceConfigIns = sectionManager1.getLimitPriceConfigIns();
            limitPriceConfigIns.setSectionId(bidSection.getId());
            limitPriceConfigIns.setSectionName(sectionManager1.getSectionName());
            limitPriceDtos.add(limitPriceConfigIns);
        }
        limitPriceDto.setLimitPrices(limitPriceDtos);
        return MsgUtil.success(limitPriceDto);
    }

    /**
     * 新增其他公告
     *
     * @param noticeDto
     * @return
     */
    @Transactional
    @PostMapping("/notice/saveOtherNotice")
    public Message saveOtherNotice(@RequestBody NoticeDTO noticeDto) {
        String valid = noticeDto.paramsValid();
        if (StrUtil.isNotEmpty(valid)) {
            return MsgUtil.fail(valid);
        }
        // 保存公告
        noticeDto.buildBaseData(1);
        boolean save = service.save(noticeDto);
        // 保存公告标段中间表关系
        NoticeBidSection noticeBidSection = new NoticeBidSection();
        noticeBidSection.setNoticeId(noticeDto.getId());
        noticeBidSection.setSectionId(noticeDto.getSectionId());
        noticeBidSection.buildBaseData(1);
        boolean saveSection = noticeBidSectionService.save(noticeBidSection);
        return MsgUtil.msg(save && saveSection);
    }

    /**
     * 其他公告列表
     *
     * @param noticeDto
     * @return
     */
    @PostMapping("/notice/info/otherNotice")
    public Message<PageResult<NoticeDTO>> infoOtherNotice(@RequestBody NoticeDTO noticeDto) {
        Long sectionId = noticeDto.getSectionId();
        if (sectionId == null) {
            return MsgUtil.fail("标段ID不能为空");
        }

        Page<NoticeDTO> noticeVos = service.listNoticeBySection(noticeDto);
        PageResult<NoticeDTO> tPageResult = PageResult.get(noticeVos);
        return MsgUtil.success(tPageResult);
    }

    /**
     * 其他公告详情
     *
     * @param noticeId
     * @return
     */
    @GetMapping("/notice/info/otherNoticeById")
    public Message<NoticeDTO> otherNoticeById(@RequestParam("noticeId") Long noticeId) {
        if (null == noticeId) {
            return MsgUtil.fail("公告id不能为空");
        }

        QueryWrapper<Notice> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().select(Notice::getNoticeTitle, Notice::getNoticeNature, Notice::getMedium, Notice::getNoticeContent, Notice::getDeployTime).eq(Notice::getId, noticeId);
        Notice notice = service.getOne(queryWrapper);
        if (notice == null) {
            return MsgUtil.fail("公告不存在");
        }
        NoticeDTO noticeDto = notice.to(NoticeDTO.class);
        noticeDto.setNoticeNatureName(Enums.nameOf(NoticeNatureEnum.class, noticeDto.getNoticeNature()));
        return MsgUtil.success(noticeDto);
    }

    /**
     * 发布公告
     *
     * @param noticeD
     * @return
     */
    @PostMapping("/notice/noticeRelease")
    public Message<Boolean> noticeRelease(@RequestBody NoticeDTO noticeD) {
        Long noticeId = noticeD.getId();
        Notice notice = service.getById(noticeD.getId());
        if (notice == null) {
            return MsgUtil.fail("公告不存在,请重新进入");
        }
        //更新公告状态
        notice.setDeployTime(LocalDateTime.now());
        notice.setDeployStatus(LogicEnum.YES.getCode());
        service.updateById(notice);

        List<NoticeBidSection> noticeBidSectionList = noticeBidSectionService.listNoticeBidSectionByNoticeId(noticeId);//标段公告中间表
        if (CollUtil.isEmpty(noticeBidSectionList)) {//TODO 最高限价公告不更新标段状态
            return MsgUtil.success();
        }
        List<Long> sectionIdList = noticeBidSectionList.stream().filter(noticeBidSection -> noticeBidSection.getNoticeId() == null)
                .map(NoticeBidSection::getSectionId).collect(Collectors.toList());
        //TODO 刷新标段状态调用公共的方法
        return MsgUtil.success();
    }

    // *********************************************************************************
    // *                             notice manage start                               *
    // *********************************************************************************

    /**
     * 新建公告时返回相应的公告信息
     *
     * @param notice
     * @return
     */
    @PostMapping("/notice/initNoticeData")
    public Message<NoticeDTO> initNoticeData(@RequestBody NoticeDTO notice) {
        Long projectId = notice.getProjectId();
        if (projectId == null) {
            return MsgUtil.msg(MsgEnum.INCORRECT_PARAM);
        }
        AbstractProject project = projectService.getByPrimaryKey(projectId);
        if (project == null) {
            return MsgUtil.fail("未查询到指定的项目信息");
        }
        notice.setNoticeNature(NoticeNatureEnum.FIRST.getCode());
        notice.setNoticeTitle(project.getProjectName() + " - 首次公告");
        // 判断是公开的还是邀请的  如果是邀请的公告名称为邀请书
        if (null != notice.getCommonType() && notice.getCommonType() == CommonTypeEnum.INVITE.getCode()) {
            notice.setNoticeTitle(project.getProjectName() + " - 邀请书");
        }
        project.to(notice);
        return MsgUtil.success(notice);
    }

    /**
     * 保存公告信息
     *
     * @param noticeDTO
     * @return
     */
    @Transactional
    @PostMapping("/notice/saveNotice")
    public Message<NoticeDTO> saveNotice(@RequestBody NoticeDTO noticeDTO) {
        NoticeManager manager = noticeDTO.to(NoticeManager.class);
        NoticeSave noticeSave = manager.getSaveService();

        // 参数验证
        String info = noticeSave.checkNoticeInfo(noticeDTO);
        if (StrUtil.isNotEmpty(info)) {
            return MsgUtil.fail(info);
        }
        //第一步保存
        if (Integer.valueOf(1).equals(noticeDTO.getNoticeFormFlag())) {
            //设置标段状态为未发布
            noticeDTO.setDeployTime(null);
            noticeDTO.setDeployStatus(DeployStatusEnum.UN_DEPLOYED.getCode());
        }

        // 保存公告
        boolean saveNotice = noticeSave.saveNotice(noticeDTO);
        if (saveNotice) {
            return MsgUtil.success(noticeDTO);
        }
        return MsgUtil.msg(MsgEnum.FAILURE);
    }

    /**
     * 查询公告列表信息
     * 指定项目下所有标段关联的公告列表
     * 按创建时间排序
     *
     * @param noticeDTO projectId 项目ID
     * @return {@link Message}
     * @update zhaojk
     */
    @PostMapping("/notice/findNoticeList")
    public Message<PageResult<NoticeDTO>> findNoticeList(@RequestBody NoticeDTO noticeDTO) {
        Page<NoticeDTO> noticePages = service.pageNoticeByProjectId(noticeDTO);
        return MsgUtil.success(PageResult.get(noticePages));
    }

    /**
     * 发布公告, 修改公告的发布状态
     *
     * @param noticeDTO id 公告ID
     * @return {@link Message}
     * @update zhaojk
     */
    @PostMapping("/notice/deploy")
    public Message<Boolean> deploy(@RequestBody NoticeDTO noticeDTO) {
        Notice notice = service.getById(noticeDTO.getId());
        if (CollUtil.isEmpty(notice.getSignFile())) {
            return MsgUtil.fail("文件还未签章,签章之后再发布");
        }
        notice.setDeployStatus(DeployStatusEnum.DEPLOYED.getCode());
        notice.buildBaseData(2);
        NoticeManager noticeManager = notice.to(NoticeManager.class);
        noticeManager.setNoticeFormFlag(1);
        NoticeSave noticeSave = noticeManager.getSaveService();
        //发布的逻辑
        String msg = noticeSave.deploy(notice);
        if (StrUtil.isNotEmpty(msg)) {
            return MsgUtil.fail(msg);
        }
        noticeDTO.setDeployTime(LocalDateTime.now());
        noticeDTO.setDeployStatus(DeployStatusEnum.DEPLOYED.getCode());
        //页面传过来的时间 有个是首次公告带过来的数据
        noticeDTO.setCreateTime(null);
        boolean update = service.updateById(noticeDTO);
        //更新标段状态
        List<NoticeBidSection> noticeBidSections = noticeBidSectionService.listNoticeBidSectionByNoticeId(notice.getId());
        if (CollUtil.isNotEmpty(noticeBidSections)) {
            for (NoticeBidSection noticeBidSection : noticeBidSections) {
                BidSection bidSection = bidSectionService.getById(noticeBidSection.getSectionId());
                if (bidSection == null) {
                    continue;
                }
                // 如果是流标需要更改状态
                // 这里加标段状态的修改是因为有可能不在开标大厅点击流标直接发流标结果公示
                if (notice.getNoticeNature().equals(NoticeNatureEnum.FAILURE.getCode())) {
                    bidSection.setFailFlag(1);
                    bidSectionService.updateById(bidSection);
                } else {
                    bidSection.to(BidSectionManager.class).refreshBidSection();
                }
            }
        }
        return MsgUtil.success(update);
    }

    /**
     * @param noticeDTO: 公告id
     * @Description: 查询公告页面的信息 (有公告id只查询这个公告的信息,有标段的查询首次公告)
     * @Author: zhongdl
     * @Date:2021/12/8 9:53
     * @return: {@link org.fzzn.core.model.msg.ResponseDto }
     * @update zhaojk
     **/
    @PostMapping("/notice/findNoticeInfo")
    public Message<NoticeDTO> findNoticeInfo(@RequestBody NoticeDTO noticeDTO) {
        Long noticeId = noticeDTO.getId();
        // 项目招标类型: 1: 公开, 2: 邀请
        Integer commonType = noticeDTO.getCommonType();
        if (noticeId == null) {
            return MsgUtil.msg(MsgEnum.INCORRECT_PARAM);
        }

        //查询公告信息和标段信息
        Notice noticeDB = service.getById(noticeId);
        noticeDTO = noticeDB.to(NoticeDTO.class);


        //设置查询是否需要报名
        AbstractProject abstractProject = projectService.getById(noticeDB.getProjectId());
        noticeDTO.setSignUpFlag(abstractProject == null ? LogicEnum.YES.getCode() : abstractProject.getSignUpFlag());
        List<BidSectionDTO> bidSectionList = bidSectionService.findSectionBondByNoticeId(noticeDTO.getId());
        if (CollUtil.isNotEmpty(bidSectionList)) {
            noticeDTO.setBidSectionList(bidSectionList);
        }

        // 判断是公开的还是邀请的  如果是邀请的需要查询邀请企业信息
        if (null != commonType && commonType == CommonTypeEnum.INVITE.getCode() && CollUtil.isNotEmpty(bidSectionList)) {
            // 查询每个标段下的投标企业
            List<NoticeBidSectionOrgDTO> bidSectionOrgDTOList = tenderInviteEnterpriseService.selectTenderInviteEnterpriseByNoticeIdAndSectionId(noticeId);
            if (CollUtil.isNotEmpty(bidSectionOrgDTOList)) {
                noticeDTO.setBidSectionOrgList(bidSectionOrgDTOList);
            }
        }

        NoticeManager noticeManager = noticeDTO.to(NoticeManager.class);
        noticeManager.setParentId(null);
        noticeManager.setProjectCode(abstractProject.getProjectCode());
        noticeManager.setProjectName(abstractProject.getProjectName());
        //带入下次变更公告数据创建人设为null
        noticeManager.setCreateName(null);
        return MsgUtil.success(noticeManager.to(NoticeDTO.class));
    }

    /**
     * 查询指定标段关联的所有公告
     *
     * @param noticeDTO
     * @return
     * @update zhaojk
     */
    @PostMapping("/notice/pageBySectionId")
    public Message<PageResult<NoticeDTO>> pageBySectionId(@RequestBody NoticeDTO noticeDTO) {
        Page<Notice> pages = service.pageNoticeBySectionId(noticeDTO);
        PageResult<Notice> result = PageResult.get(pages);
        PageResult<NoticeDTO> noticeDTOPageResult = result.transferTo(NoticeDTO.class);
        return MsgUtil.success(noticeDTOPageResult);
    }

    /**
     * 门户网站 查询公告
     *
     * @param noticePortalDTO
     * @return
     */
    @PostMapping("/notice/noticeList")
    public Message<PageResult<NoticePortalDTO>> noticeList(@RequestBody NoticePortalDTO noticePortalDTO) {
        if (noticePortalDTO == null) {
            return MsgUtil.fail(MsgEnum.INCORRECT_PARAM.msg());
        }
        Page<NoticePortalDTO> noticePortalDTOPage = service.pageNotice(noticePortalDTO);
        for (NoticePortalDTO noticeDTO : noticePortalDTOPage.getRecords()) {
            // 根据投标截止时间判断投标状态
            if (noticeDTO.getOpenBidTime() != null) {
                if (DateUtil.getMillis2() > noticeDTO.getOpenBidTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) {
                    noticeDTO.setApplyStatus(2);
                } else {
                    noticeDTO.setApplyStatus(1);
                }
            }
            // 日期格式化
            if (noticeDTO.getCreateTime() != null) {
                noticeDTO.setPublishDate(noticeDTO.getCreateTime());
            }
        }
        return MsgUtil.success(PageResult.get(noticePortalDTOPage));
    }

    /**
     * 门户网站 查询公告详情
     *
     * @param noticePortalDTO
     * @return
     */
    @Transactional
    @PostMapping("/notice/noticeDetail")
    public Message<NoticePortalDTO> noticeDetail(@RequestBody NoticePortalDTO noticePortalDTO) {
        if (null == noticePortalDTO) {
            return MsgUtil.fail(MsgEnum.INCORRECT_PARAM.msg());
        }
        //点击量，每次调用这个接口 该公告的点击量+1
        NoticePortalDTO portalDTO = service.findNoticeByNoticeId(noticePortalDTO);
        if (portalDTO != null) {
            Notice notice = portalDTO.to(Notice.class);
            Integer num = notice.getClickCount();
            if (num == null) {
                num = 0;
            }
            notice.setClickCount(num + 1);
            portalDTO.setClickCount(num + 1);
            service.updateById(notice);
            if (portalDTO.getCreateTime() != null) {
                portalDTO.setPublishDate(portalDTO.getCreateTime());
            }
        }
        return MsgUtil.success(portalDTO);
    }

    /**
     *
     * @Description: 查询需要推送的公告
     * @Author: zhongdl
     * @Date:2022/2/23 9:07
     * @param noticeDTO
     * @return: {@link Message< List< NoticeDTO>> }
     **/
    @PostMapping("/notice/listPushNotice")
    public Message<List<NoticeDTO>> listPushNotice(@RequestBody NoticeDTO noticeDTO) {
        List<NoticeDTO> noticeDTOS = service.listPushNotice();
        if (CollUtil.isEmpty(noticeDTOS)) {
            return MsgUtil.success(noticeDTOS);
        }
        for (NoticeDTO notice : noticeDTOS) {
            List<NoticeBidSection> noticeBidSections = noticeBidSectionService.listNoticeBidSectionByNoticeId(notice.getId());
            notice.setNoticeBidSections(noticeBidSections);
        }
        return MsgUtil.success(noticeDTOS);
    }

    /**
     *
     * @Description: 查询公告的标段列表
     * @Author: zhongdl
     * @Date:2022/3/4 10:37
     * @param noticeDTO:
     * @return: {@link Message< List< BidSectionDTO>> }
     **/
    @PostMapping("/notice/listNoticeBidSection")
    public Message<List<BidSectionDTO>> listNoticeBidSection(@RequestBody NoticeDTO noticeDTO) {
        List<BidSectionDTO> bidSectionDTOS = noticeBidSectionService.listNoticeBidSection(noticeDTO.getId());
        return MsgUtil.success(bidSectionDTOS);
    }

    /**
     * 根据标段id查询公告列表
     * @param noticeListDTO
     * @return
     * @author ljs
     * @date 2022-3-31 09:44:25
     */
    @PostMapping("/notice/listNoticeBySectionId")
    public Message<List<NoticeListVo>> listNoticeBySectionId(@RequestBody NoticeListDTO noticeListDTO) {
        List<Notice> noticeList = service.listNoticeBySectionId(noticeListDTO);
        List<NoticeListVo> noticeListVoList = new ArrayList<>();
        for (Notice notice : noticeList) {
            NoticeListVo noticeListVo = new NoticeListVo();
            BeanUtil.copyProperties(notice, noticeListVo);
            // 设置公告类型名称
            String noticeNatureName = Enums.nameOf(NoticeNatureEnum.class, notice.getNoticeNature());
            noticeListVo.setNoticeNatureName(noticeNatureName);
            // 设置公告状态名称
            String deployStatusName = Enums.nameOf(DeployStatusEnum.class, notice.getDeployStatus());
            noticeListVo.setDeployStatusName(deployStatusName);
            // 设置操作时间 --已发布：发布时间  未发布：最后保存时间
            if (notice.getDeployTime() != null) {
                noticeListVo.setOperationTime(notice.getDeployTime());
            } else if (notice.getUpdateTime() != null) {
                noticeListVo.setOperationTime(notice.getUpdateTime());
            } else {
                noticeListVo.setOperationTime(notice.getCreateTime());
            }
            noticeListVoList.add(noticeListVo);
        }
        return MsgUtil.success(noticeListVoList);
    }

    /**
     * 根据Id查询公告
     *
     * @author yuezheng
     * @param noticeDTO
     * @return Notice
     * @date 2022/4/19 4:04 PM
     */
    @PostMapping("/notice/findById")
    public Message<Notice> findNoticeById(@RequestBody NoticeDTO noticeDTO) {
        Notice notice = service.getById(noticeDTO);
        return MsgUtil.success(notice);
    }

    /**
     * 门户使用查询关联公告
     * @param noticePortalDTO
     * @return
     */
    @PostMapping("/portal/findNoticesBySectionId")
    public Message<List<Notice>> findNoticesBySectionId(@RequestBody NoticePortalDTO noticePortalDTO) {
        NoticeListDTO noticeListDTO = new NoticeListDTO();
        noticeListDTO.setSectionId(Long.valueOf(noticePortalDTO.getSectionId()));
        List<Notice> noticeList = service.listNoticeBySectionId(noticeListDTO);
        List<Notice> notices = new ArrayList<>();
        for (Notice notice : noticeList) {
            if (!notice.getNoticeNature().equals(noticePortalDTO.getNoticeNature())) {
                notices.add(notice);
            }
        }
        return MsgUtil.success(notices);
    }

    /**
     * @Description: 根据项目ID查询公告
     *
     * @author yuezheng
     * @param noticeDTO
     * @return org.fzzn.core.model.msg.Message
     * @date 2022/6/30 17:23
     */
    @PostMapping("/notice/findNoticeByProjectId")
    public Message findNoticeByProjectId(@RequestBody NoticeDTO noticeDTO) {
        if (noticeDTO == null || noticeDTO.getProjectId() == null) {
            return MsgUtil.fail(MsgEnum.INCORRECT_PARAM_TYPE.msg());
        }
        List<Notice> noticeList = this.service.findNoticeByProjectId(noticeDTO.getProjectId());
        return MsgUtil.success(noticeList);
    }
}
